from sqlalchemy import Column, Integer, String, DateTime, Text, BigInteger, func, Enum
from ..database import Base

class Question(Base):
    __tablename__ = 'questions'

    id = Column(BigInteger, primary_key=True, autoincrement=True, comment="主键：自增编号")
    content = Column(Text, nullable=False, comment="题目内容")
    answer = Column(Text, nullable=False, comment="正确答案")
    question_type = Column(Enum('choice','fill','short'), nullable=False, comment="题目类型：选择题(choice)、填空题(fill)、简答题(short)")
    difficulty = Column(Integer, nullable=False, comment="难度等级（1-10）")
    major = Column(String(50), nullable=True, comment="所属专业")
    course = Column(String(50), nullable=False, comment="所属课程")
    subject = Column(String(50), nullable=True, comment="考查主题")
    analysis = Column(Text, nullable=True, comment="答案解析")
    question_time = Column(Integer, nullable=False, comment="建议答题时间（分钟）")
    created_at = Column(DateTime, server_default=func.now(), comment="创建时间")
    updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment="更新时间")

